// components/address_item/address.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    data: {
      type: Object,
      value: null
    },
    mapping: {
      type: Object,
      value: null
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    area: null
  },
  lifetimes: {
    attached: function () {
      // 在组件实例进入页面节点树时执行
      const a = this.getAreaFromData()
      this.setData({
        area: a
      })
    },
    detached: function () {
      // 在组件实例被从页面节点树移除时执行
    },
  },
  /**
   * 组件的方法列表
   */
  methods: {
    getAreaFromData: function () {
      const d = this.data.data
      if (!d) return ""
      const a = d.area
      if (a) {
        return a.join('')
      }
    },
    click: function (event) {
      const d = event.detail
      if (d === "cell") {
        this.triggerEvent("select", this.data.data)
      }
    },
    rightClick: function (event) {
      const d = event.target.dataset
      const action = d.action
      this.triggerEvent(action, this.data.data)
    }
  }
})